home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Tetris Light 1.0 / source / windows.c < prev    next >
Text File  |  1993-07-18  |  3KB  |  89 lines

  1. /**********************************************************************\
  2.  
  3. File:        windows.c
  4.  
  5. Purpose:    This module implements a dispatch table mechanism which is
  6.             used to handle window events.
  7.             
  8.  
  9. ``Tetris Light'' - a simple implementation of a Tetris game.
  10. Copyright (C) 1993 Hoylen Sue
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program; see the file COPYING.  If not, write to the
  24. Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  25.  
  26. \**********************************************************************/
  27.  
  28. #include "local.h"
  29. #include "windows.h"
  30.  
  31. /*--------------------------------------------------------------------*/
  32.  
  33. void window_mouseDown(WindowPtr wind, Point where)
  34. /* Sends a mouseDown event to the given window. */
  35. {
  36.     register Wind_table *table = (Wind_table *) GetWRefCon(wind);
  37.     
  38.     if (table->mouseDown_handler != 0)
  39.         table->mouseDown_handler(where);
  40. }
  41.  
  42. /*--------------------------------------------------------------------*/
  43.  
  44. void window_key(WindowPtr wind, unsigned char code, unsigned char ascii)
  45. /* Sends a key press event to the given window. */
  46. {
  47.     register Wind_table *table = (Wind_table *) GetWRefCon(wind);
  48.     
  49.     if (table->key_handler != 0)
  50.         table->key_handler(code, ascii);
  51. }
  52.  
  53. /*--------------------------------------------------------------------*/
  54.  
  55. void window_update(WindowPtr wind)
  56. /* Sends an update event to the given window. */
  57. {
  58.     register Wind_table *table = (Wind_table *) GetWRefCon(wind);
  59.  
  60.     BeginUpdate(wind);
  61.     if (table->update_handler != 0)
  62.         table->update_handler();
  63.     EndUpdate(wind);
  64. }
  65.  
  66. /*--------------------------------------------------------------------*/
  67.  
  68. void window_activate(WindowPtr wind)
  69. /* Sends an activate event to the given window. */
  70. {
  71.     register Wind_table *table = (Wind_table *) GetWRefCon(wind);
  72.     
  73.     if (table->activate_handler != 0)
  74.         table->activate_handler();
  75. }
  76.  
  77. /*--------------------------------------------------------------------*/
  78.  
  79. void window_deactivate(WindowPtr wind)
  80. /* Sends a deactivate event to the given window. */
  81. {
  82.     register Wind_table *table = (Wind_table *) GetWRefCon(wind);
  83.     
  84.     if (table->deactivate_handler != 0)
  85.         table->deactivate_handler();
  86. }
  87.  
  88. /*--------------------------------------------------------------------*/
  89.